/*
 * Copyright (c) 2015 Uwantsoft Ltd.
 * www.uwantsoft.com
 * All rights reserved.
 *
 * This software is the confidential and proprietary information of
 * Uwantsoft ("Confidential Information").
 * You shall not disclose such Confidential Information and shall use
 * it only in accordance with the terms of the license agreement you
 * entered into with Uwantsoft.
 */

package com.uwantsoft.interfaces.web.controller.web;

import com.uwantsoft.business.facade.UserFacadeImpl;
import com.uwantsoft.business.facade.dto.user.UserDto;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.validation.BindingResult;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;

import javax.annotation.Resource;
import javax.validation.Valid;

/**
 * @author Chuanbao
 */
@Controller
public class LoginController {

    @Resource(name = "userFacade")
    private UserFacadeImpl userFacade;


    @RequestMapping(value = {"/login","/"},method = RequestMethod.GET)
    public String login(){
        return "backend/login";
    }


    @RequestMapping(value = {"/registry"},method = RequestMethod.GET)
    public String get(){
        return "backend/registry";
    }

    @RequestMapping(value = {"/registry"},method = RequestMethod.POST)
    public String post(@Valid UserDto userDto,BindingResult result,Model model){
        return "backend/registry";
    }

    @RequestMapping(value = {"/registry/ajax"},method = RequestMethod.POST)
    public @ResponseBody UserDto postAjax(@Valid @RequestBody UserDto userDto){
        return userDto;
    }
}
